package com.base.api.bds;

import com.base.api.pms.PmsPublicSqlQuery;
import org.springframework.stereotype.Component;

import java.text.MessageFormat;
import java.util.Map;

@Component
public class BdsSqlQuery extends PmsPublicSqlQuery {

    @Override
    public String splicSql(String sql, Map<String, Object> param) {
        String param1 = "";
        if (param != null && param.get("keyWords") != null && !"".equals("keyWords")) {
            param1 =
                    MessageFormat.format("AND (\n" +
                            "         upper(SPELL_CODE) LIKE concat(\"%\",upper(\"{0}\"),\"%\")\n" +
                            "         or upper(TYPE_NAME) LIKE concat(\"%\",upper(\"{0}\"),\"%\")\n" +
                            "         or upper(STANDARD_CODE) LIKE concat(\"%\",upper(\"{0}\"),\"%\")\n" +
                            "         )", param.get("keyWords"));
        }
        return MessageFormat.format(sql, param1);
    }
}
